<template>
    <a-tree-select
        v-model:value="value"
        show-search
        style="width: 100%"
        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
        placeholder="请选择"
        allow-clear
        multiple
        tree-default-expand-all
        :tree-data="treeData"
    ></a-tree-select>
</template>
<script setup lang="ts">
import type { TreeSelectProps } from 'ant-design-vue'
import { ref, watch, inject } from 'vue'
const globalGridAttr: any = inject('globalGridAttr')
const value = ref<string[]>(globalGridAttr.gudingRen)
const treeData = ref<TreeSelectProps['treeData']>([
  {
    title: 'parent 1',
    value: 'parent 1',
    children: [
      {
        title: 'parent 1-0',
        value: 'parent 1-0',
        children: [
          {
            title: 'my leaf',
            value: 'leaf1'
          },
          {
            title: 'your leaf',
            value: 'leaf2'
          }
        ]
      },
      {
        title: 'parent 1-1',
        value: 'parent 1-1'
      }
    ]
  }
])
const emit = defineEmits(['change'])
watch(value, () => {
  //   console.log('select', value.value)
  //   globalGridAttr.gudingRen = value.value
  emit('change', value.value)
})
</script>
